//
//  main.m
//  5-10复习
//
//  Created by 钟纪旺 on 16/5/10.
//  Copyright © 2016年 zjw. All rights reserved.
//

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        // insert code here...
        NSString *path = @"/Users/zhongjiwang/Desktop/cbv.vcf";
        NSError *err;
        NSString *vcf = [[NSString alloc]initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&err];
        if (err !=0) {
            NSLog(@"%@",err);
        }
         NSArray *arr =[vcf componentsSeparatedByString:@"\n"];
        for (NSString *lien in arr) {
            if ([lien hasPrefix:@"BEGIN"]) {
                NSLog(@"读取中....");
            }if ([lien hasPrefix:@"END"]) {
                NSLog(@"结束读取......");
            }if ([lien hasPrefix:@"TEL"]) {
                NSArray *tels = [lien componentsSeparatedByString:@":"];
                NSString *last = tels.lastObject;
                
                
                
                NSLog(@"电话:%@",last);
            }if ([lien hasPrefix:@"FN"]) {
                NSArray *names = [lien componentsSeparatedByString:@":"];
                NSString *name =names.lastObject;
                name = [name stringByReplacingOccurrencesOfString:@"=" withString:@"%"];
                name = name.stringByRemovingPercentEncoding;
                //percent 百分号
                NSLog(@"名字:%@",name);
            }
            }
        }
    
    return 0;
}
